package org.charles.zhifou.model.dto.user;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.charles.zhifou.common.enums.CodeToEnumDeserializer;
import org.charles.zhifou.enums.UserRoleEnum;
import org.hibernate.validator.constraints.Length;

import java.io.Serial;
import java.io.Serializable;

/**
 * 用户更新请求 (注: 此处修改过)
 *
 * @author Charles
 * @version 1.0
 */
@Data
public class UserUpdateRequest implements Serializable {
    @Schema(description = "用户 id")
    @Min(value = 1, message = "id 必须大于 0")
    @NotNull(message = "id 不能为空")
    private Long id;

    @Schema(description = "账号")
    @Length(min = 4, max = 100, message = "用户账号长度不能小于 4 个字符且不能大于 100 个字符")
    private String userAccount;

    @Schema(description = "密码")
    @Length(min = 8, max = 100, message = "用户密码长度不能小于 8 个字符且不能大于 100 个字符")
    private String userPassword;

    @Schema(description = "微信开放平台 id")
    @Length(max = 256, message = "微信 openId 长度不能超过 256 个字符")
    private String unionId;

    @Schema(description = "公众号 openId")
    @Length(max = 256, message = "公众号 openId 长度不能超过 256 个字符")
    private String mpOpenId;

    @Schema(description = "用户昵称")
    @Length(max = 256, message = "用户昵称长度不能超过 256 个字符")
    private String userName;

    @Schema(description = "用户头像")
    @Length(max = 512, message = "用户头像 URL 长度不能超过 512 个字符")
    private String userAvatar;

    @Schema(description = "用户简介")
    @Length(max = 512, message = "用户简介长度不能超过 512 个字符")
    private String userProfile;

    @Schema(description = "用户角色: 0-普通用户, 1-管理员, 2-被封号")
    @JsonDeserialize(using = CodeToEnumDeserializer.class)
    private UserRoleEnum userRole;

    @Serial
    private static final long serialVersionUID = 1L;
}